home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / fun / wordmacs < prev    next >
Encoding:
Text File  |  1996-09-27  |  4.2 KB  |  182 lines

  1. @if-using not(ocl-file-wordmacs)
  2.   @use (ocl-file-wordmacs)
  3.   ;OCL{{{}}}
  4.   ;OCL{{{  libs
  5.   @if-using not(ocl-file-error) @lib error @fi
  6.   ;OCL}}}
  7.   ;OCL{{{  character-classes
  8.   (defset word-char ( alpha digit ))
  9.   ;OCL}}}
  10.  
  11.   ;OCL{{{  backward-word           move one word left
  12.   ;OCL{{{  word-line-up            go to end of previous line for word
  13.   (defmac word-line-up (
  14.     if test-top ( failed ) fi
  15.     previous-line
  16.     end-of-line
  17.   ))
  18.   ;OCL}}}
  19.   ;OCL{{{  blank-left              skip the whitespace left to next word
  20.   (defmac blank-left (
  21.     while not(test-char-set word-char)
  22.      ;OCL{{{  back or line up
  23.      ( if =(+(store-pos -1) 0)
  24.         ( word-line-up )
  25.        else
  26.         ( backward-character )
  27.        fi
  28.      )
  29.      ;OCL}}}
  30.   ))
  31.   ;OCL}}}
  32.   ;OCL{{{  start-word              move to start of current word
  33.   (defmac start-word (
  34.      ;OCL{{{  skip word to next space
  35.      while test-char-set word-char
  36.       ( if test-begin-line
  37.           ( return-from-macro )
  38.         else
  39.           ( backward-character )
  40.         fi
  41.       )
  42.      ;OCL}}}
  43.      forward-character
  44.   ))
  45.   ;OCL}}}
  46.  
  47.   (deffun backward-word (
  48.     if in-prompt ( return-from-macro ) fi
  49.     ;OCL{{{  one step left
  50.     if test-begin-line
  51.       ( word-line-up )
  52.     else
  53.       ( backward-character )
  54.     fi
  55.     ;OCL}}}
  56.     blank-left
  57.     start-word
  58.   ))
  59.   ;OCL}}}
  60.   ;OCL{{{  forward-word            move to next word right
  61.   ;OCL{{{  word-line-down          go to beginning of next line for word
  62.   (defmac word-line-down (
  63.     if test-bottom ( failed ) fi
  64.     next-line
  65.     beginning-of-line
  66.   ))
  67.   ;OCL}}}
  68.   ;OCL{{{  blank-right             skip the whitespace right to next word
  69.   (defmac blank-right (
  70.     while not(test-char-set word-char)
  71.      ;OCL{{{  right or down
  72.      ( if test-end-line
  73.          ( word-line-down )
  74.        else
  75.          ( forward-character )
  76.        fi
  77.      )
  78.      ;OCL}}}
  79.   ))
  80.   ;OCL}}}
  81.   ;OCL{{{  end-word                skip to whitespace after current word
  82.   (defmac end-word (
  83.      while test-char-set word-char
  84.        ( forward-character )
  85.   ))
  86.   ;OCL}}}
  87.  
  88.   (deffun forward-word (
  89.     if in-prompt ( return-from-macro ) fi
  90.     ;OCL{{{  end word or next-line
  91.     if test-end-line
  92.       ( word-line-down )
  93.     else
  94.       ( end-word )
  95.     fi
  96.     ;OCL}}}
  97.     blank-right
  98.   ))
  99.   ;OCL}}}
  100.  
  101.   ;OCL{{{  case-word-capitalize    capitalize current (or next) word
  102.   (deffun case-word-capitalize (
  103.     if in-prompt ( return-from-macro ) fi
  104.     ;OCL{{{  check position
  105.     if or(test-view,and(test-top =(set-enter 0)))
  106.       ( failed )
  107.     fi
  108.     ;OCL}}}
  109.     ;OCL{{{  maybe move to next word
  110.     if not(test-char-set word-char)
  111.      ( forward-word )
  112.     fi
  113.     ;OCL}}}
  114.     ;OCL{{{  capitalize first char
  115.     if test-char-set lower (case-character-toggle ) fi
  116.     forward-character
  117.     ;OCL}}}
  118.     ;OCL{{{  all following word-chars to lowercase
  119.     while test-char-set word-char
  120.      ( if test-char-set upper ( case-character-toggle ) fi
  121.        forward-character
  122.      )
  123.     ;OCL}}}
  124.   ))
  125.   ;OCL}}}
  126.   ;OCL{{{  case-word-upper         all chars of current (or next) word to uppercase
  127.   (deffun case-word-upper (
  128.     if in-prompt ( return-from-macro ) fi
  129.     ;OCL{{{  check position
  130.     if or(test-view and(test-top =(set-enter 0)))
  131.       ( failed )
  132.     fi
  133.     ;OCL}}}
  134.     ;OCL{{{  maybe move to next word
  135.     if not(test-char-set word-char)
  136.      ( forward-word )
  137.     fi
  138.     ;OCL}}}
  139.     ;OCL{{{  all chars to uppercase
  140.     do
  141.      ( if test-char-set lower ( case-character-toggle ) fi
  142.        forward-character
  143.      )
  144.     while test-char-set word-char
  145.     ;OCL}}}
  146.   ))
  147.   ;OCL}}}
  148.   ;OCL{{{  case-word-lower         all chars of current (or next) word to lowercase
  149.   (deffun case-word-lower (
  150.     if in-prompt ( return-from-macro ) fi
  151.     ;OCL{{{  check position
  152.     if or(test-view,and(test-top =(set-enter 0)))
  153.       ( failed )
  154.     fi
  155.     ;OCL}}}
  156.     ;OCL{{{  maybe move to next word
  157.     if not(test-char-set word-char)
  158.      ( forward-word )
  159.     fi
  160.     ;OCL}}}
  161.     ;OCL{{{  all chars to lowercase
  162.     do
  163.      ( if test-char-set upper ( case-character-toggle ) fi
  164.        forward-character
  165.      )
  166.     while test-char-set word-char
  167.     ;OCL}}}
  168.   ))
  169.   ;OCL}}}
  170.   ;OCL{{{  undeclares
  171.   ( undeclare
  172.      ( word-line-up 
  173.        blank-left
  174.        start-word
  175.        word-line-down
  176.        blank-right
  177.        end-word
  178.      ) 
  179.   )
  180.   ;OCL}}}
  181. @fi
  182.